package com.jims.api.v1.controller.common;

import com.jims.master.common.data.Message;
import com.jims.master.common.utils.SecurityUtil;
import com.jims.master.modules.base.user.entity.SysDepartment;
import com.jims.master.modules.base.user.service.SysDepartmentService;
import com.jims.master.modules.doctor.area.entity.SysArea;
import com.jims.master.modules.doctor.area.service.SysAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 科室信息
 * @author jict
 * @version 2017-11-21
 */
@RestController
@RequestMapping(value = "department")
public class SysDepartmentController {
    @Autowired
    private SysDepartmentService sysDepartmentService;

    /**
     * @Title:
     * @Description: （获取父科室）
     * @return
     * @author jict
     * @date 2017/11/22
     * @throws
     */
    @RequestMapping(value = "V100/getDepartment",method ={RequestMethod.GET,RequestMethod.POST})
    public String getDepartment() {
        Message msg=new Message();
        List<SysDepartment> list = sysDepartmentService.getParentPart();
        msg.setData(list);
        return SecurityUtil.encryptMsgData(msg);
    }

    /**
     * @Title:
     * @Description: （获取父科室）
     * @param parentId 父级id
     * @return
     * @author WangYQ
     * @date 2018/04/12
     * @throws
     */
    @RequestMapping(value = "V100/getByParentId",method ={RequestMethod.GET,RequestMethod.POST})
    public String getByParentId(@RequestParam(required = true)String parentId) {
        Message msg=new Message();
        List<SysDepartment> list = sysDepartmentService.getByParentId(parentId);
        msg.setData(list);
        return SecurityUtil.encryptMsgData(msg);
    }

    /**
     * @Title:
     * @Description: （获取一级科室）
     * @return
     * @author jicunteng
     * @date 2018/04/25
     * @throws
     */
    @RequestMapping(value = "V100/getSysDepartment",method ={RequestMethod.GET,RequestMethod.POST})
    public String getSysDepartment() {
        Message msg=new Message();
        List<SysDepartment> list = sysDepartmentService.getSysDepartment();
        msg.setData(list);
        return SecurityUtil.encryptMsgData(msg);
    }
}
